package net.vinote.smart.platform.service.handler;

import net.vinote.smart.platform.module.database.bo.BizObject;
import net.vinote.smart.platform.service.dw.handler.CommonHandler;
import net.vinote.smart.platform.service.dw.handler.HandlerPerimissionAnnotation;
import net.vinote.smart.platform.service.util.Permission;
import net.vinote.smart.platform.service.util.Permission.PermissionEnum;

@HandlerPerimissionAnnotation(
		update = @Permission(PermissionEnum.SMART_TABLE_OBJECT_UPDATE),
		query = @Permission(PermissionEnum.SMART_TABLE_OBJECT_QUERY),
		insert = @Permission(PermissionEnum.SMART_TABLE_OBJECT_INSERT),
		delete = @Permission(PermissionEnum.SMART_TABLE_OBJECT_DELETE))
public class TableObjectInfoHandler extends CommonHandler {

	@Override
	public void initDisplayForEdit(BizObject bo) {
		setReadOnly("TableName,FieldName", true);
	}

	@Override
	public void initDisplayForAdd(BizObject bo) {
		String tableName = request.getParameter("tableName");
		if (tableName != null) {
			setDefaultValue("TableName", tableName);
			setReadOnly("TableName", true);
		}
	}

}
